package com.yuanshuai;

import com.alibaba.druid.pool.DruidDataSource;
import com.yuanshuai.config.ServerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableConfigurationProperties({ServerConfig.class})
public class Configuration9Application {

    @Bean
    @ConfigurationProperties(prefix = "datasource")
    public DruidDataSource dataSource(){
        DruidDataSource ds = new DruidDataSource();
        return ds;
    }


    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(Configuration9Application.class, args);
        ServerConfig bean = run.getBean(ServerConfig.class);
        System.out.println(bean);

        DruidDataSource bean1 = run.getBean(DruidDataSource.class);
        System.out.println(bean1.getDriverClassName());
    }

}
